﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using DAL;

namespace StudentManagerPro
{
    public partial class AdminLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ibtnLogin_Click(object sender, ImageClickEventArgs e)
        {
            SysAdmin admin = new SysAdmin
            {
                AdminName = this.txtUserId.Text.Trim(),
                LoginPwd = this.txtPwd.Text.Trim(),
            };
            //调用后台
            try
            {
                admin = new SysAdminService().AdminLogin(admin);
                if (admin == null)
                {
                    this.ltaInfo.Text = "<script>alert('用户名或密码错误!')</script>";
                }
                else
                {
                    Session["CurrentUser"] = admin;
                    Response.Redirect("~/Default.aspx",false);
                }
            }
            catch (Exception ex)
            {
                this.ltaInfo.Text = "<script type='text/javascript'>alert('" + ex.Message + "')</script>";
            }


        }
    }
}